package com.pavelk.orion
{	
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	
	import org.puremvc.as3.utilities.loadup.controller.LoadupResourceLoadedCommand;
	import org.puremvc.as3.utilities.loadup.controller.LoadupResourceFailedCommand;

	import com.pavelk.orion.controller.*;	
	
	public class ApplicationFacade extends Facade implements IFacade
	{
        
        public static function getInstance() : ApplicationFacade 
        {
            return ( instance ? instance : new ApplicationFacade() ) as ApplicationFacade;  
        }
        
        public function startup( root:Object, flashVars:Object ) : void
        {
        	var arg:Object = {
        						st:root,
        						fv:flashVars
        	}
        	sendNotification( ApplicationConstants.CMD_STARTUP, arg );
        }
        
        override protected function initializeController() : void 
        {
            super.initializeController();
            
           	registerCommand( ApplicationConstants.CMD_STARTUP, StartupCommand );
 
         	registerCommand( ApplicationConstants.SITE_DATA_LOADED, LoadupResourceLoadedCommand );
         	registerCommand( ApplicationConstants.ASSETS_LOADED, LoadupResourceLoadedCommand );
         	registerCommand( ApplicationConstants.FONTS_LOADED, LoadupResourceLoadedCommand );
 
         	registerCommand( ApplicationConstants.SITE_DATA_FAILED, LoadupResourceFailedCommand );
         	registerCommand( ApplicationConstants.ASSETS_FAILED, LoadupResourceFailedCommand );
			registerCommand( ApplicationConstants.FONTS_FAILED, LoadupResourceFailedCommand );
			
			registerCommand( ApplicationConstants.CMD_ASSETS, AssetCommand );
        }
        
        /*
        private function registerResourceLoadedCommand( notificationName:String ) :void 
        {
	    	registerCommand( notificationName, LoadupResourceLoadedCommand );
	    }
	        
	    private function registerResourceFailedCommand( notificationName:String ) :void 
	    {
	        registerCommand( notificationName, LoadupResourceFailedCommand );
	    }
	    */
	}
}